package org.istt.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * File entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TBL_FORM", schema = "dbo", catalog = "onegate")
public class Form extends BaseObject<String> implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7537235430889647821L;
	// Fields
	/* FileCode + YYYYMMDDHHMMSS */
	private String id;
	private Category category;
	
	private String fieldLabel;
	private String fieldName;
	private String fieldValue;
	private Integer position;
	private FieldType fieldType;
	private ValidatorType validatorType;
	
	// Constructors

	/** default constructor */
	public Form() {
	}

	// Property accessors
	@Id
	@Column(name = "ID", unique = true, nullable = false)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CATEGORY_ID", nullable = false)
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	public String getFieldLabel() {
		return fieldLabel;
	}

	public void setFieldLabel(String fieldLabel) {
		this.fieldLabel = fieldLabel;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public String getFieldValue() {
		return fieldValue;
	}

	public void setFieldValue(String fieldValue) {
		this.fieldValue = fieldValue;
	}
	
	@Column
	public Integer getPosition() {
		return position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FIELD_TYPE_ID")
	public FieldType getFieldType() {
		return fieldType;
	}

	public void setFieldType(FieldType fieldType) {
		this.fieldType = fieldType;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "VALIDATOR_TYPE_ID")
	public ValidatorType getValidatorType() {
		return validatorType;
	}

	public void setValidatorType(ValidatorType validatorType) {
		this.validatorType = validatorType;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof Form)) return false;
		final Form ps = (Form) o;
        if (!getId().equals(ps.getId())) return false;
		return true;
	}
	
	@Override
	public int hashCode() {
		int result;
		result = id.hashCode();
		result = 29 * result;
		return result;
	}

	@Override
	public String toString() {
		return null;
	}
	
}